//
//  MerchantResourceVModel.m
//  EMMApp
//
//  Created by Mac on 2017/8/16.
//  Copyright © 2017年 YiXun. All rights reserved.
//

#import "MerchantResourceVModel.h"
#import "GetMerchantResourceApi.h"

@interface MerchantResourceVModel ()

@end

@implementation MerchantResourceVModel

static NSObject *lock;

+ (MerchantResourceVModel *)merchantResourceVModel {
    static MerchantResourceVModel *merchat = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        merchat = [[MerchantResourceVModel alloc] init];
        lock = [[NSObject alloc] init];
    });
    return merchat;
}

- (void)startMerchantResourceVModel{
    [self postGetMerchantResourceApi];
}

- (void)postGetMerchantResourceApi {
    GetMerchantResourceApi *api = [[GetMerchantResourceApi alloc] initWith];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        GetMerchantResourceApi *result = (GetMerchantResourceApi *)request;
        if (result.isSuccess) {
            GetMerchantResource *get = result.resultData;
            NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
            [userdf setObject:get.necessary forKey:@"necessary"];
            [userdf synchronize];
        } else {
            
        }
    } failure:^(YTKBaseRequest *request) {
      
    }];
}

@end
